<?php

namespace JsonLowCode\UI;

use JsonLowCode\Schema;
use JsonLowCode\Traits\Props\HasAnimated;
use JsonLowCode\Traits\Props\HasCircle;
use JsonLowCode\Traits\Props\HasHeight;
use JsonLowCode\Traits\Props\HasRound;
use JsonLowCode\Traits\Props\HasSize;
use JsonLowCode\Traits\Props\HasWidth;

/**
 * 骨架屏组件 NSkeleton
 * @method static Skeleton make(string|int $width = null,string|int $height = null, string $size = 'medium') Skeleton组件
 */
class Skeleton extends Schema
{

    protected string $componentName = "NSkeleton";

    use HasRound, HasWidth, HasHeight, HasAnimated, HasCircle, HasSize;


    /**
     * @param string|int|null $width
     * @param string|int|null $height
     * @param string $size 'small' | 'medium' | 'large'
     */
    public function __construct(string|int $width = null,string|int $height = null, string $size = 'medium')
    {
        parent::__construct();
        $width!==null && $this->width($width);
        $height!==null && $this->height($height);
        $this->size($size);
    }

    /**
     * 重复次数
     * @param int|string $repeat
     * @return $this
     */
    public function repeat(int|string $repeat = 1): static
    {
        return $this->prop('repeat', $repeat);
    }

    /**
     * 是否文本骨架
     * @param bool|string $bool
     * @return $this
     */
    public function text(bool|string $bool = true): static
    {
        return $this->prop('text', $bool);
    }

    /**
     * 是否显示为直角骨架
     * @param bool|string $bool
     * @return $this
     */
    public function sharp(bool|string $bool = true): static
    {
        return $this->prop('sharp', $bool);
    }

}
